package com.spark.usermusicService.controller;

import com.spark.R;
import com.spark.hander.MyMetaObjectHandler;
import com.spark.usermusicService.entity.User;
import com.spark.usermusicService.service.RegisterService;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhouqichun
 * @version 1.0
 * @date 2021/7/1 - 07 - 01 - 15:11
 * @description 注册Controller层
 */
@RestController
@RequestMapping("/usermusicService/")
@CrossOrigin
public class RegisterController {
    //注入RegisterService
    @Autowired
    private RegisterService registerService;
    @Autowired
    private MyMetaObjectHandler myMetaObjectHandler;

    @PostMapping("register")
    public R register(@RequestBody User user){
        //初始化一些字段
        myMetaObjectHandler.insertFill(SystemMetaObject.forObject(user));
        //调用Service层
        return registerService.register(user);
    }
}
